<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5shiv.js" th:src="@{/lib/html5shiv.js}"></script>
	<script type="text/javascript" src="lib/respond.min.js" th:src="@{/lib/respond.min.js}"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css" th:href="@{/h-ui/css/H-ui.min.css}" />
	<link rel="stylesheet" type="text/css" href="h-ui.admin/css/H-ui.admin.css" th:href="@{/h-ui.admin/css/H-ui.admin.css}"/>
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
	<link rel="stylesheet" type="text/css" href="h-ui.admin/skin/default/skin.css" th:href="@{/h-ui.admin/skin/default/skin.css}" id="skin" />
	<link rel="stylesheet" type="text/css" href="h-ui.admin/css/style.css" th:href="@{/h-ui.admin/css/style.css}" />
	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" th:src="@{/lib/DD_belatedPNG_0.0.8a-min.js}"></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<!--/meta 作为公共模版分离出去-->

<title>转跟进人</title>
<link href="lib/webuploader/0.1.5/webuploader.css" th:href="@{/lib/webuploader/0.1.5/webuploader.css}" rel="stylesheet" type="text/css" />
</head>
<body>
<input type="hidden" id="id" name="id" th:value="${id}"/>
<input type="hidden" id="followUserId" name="followUserId" th:value="${followUserId}"/>

<div class="page-container">
	<form class="form form-horizontal" id="form-article-add">
		<!--<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">原跟进人：</label>
			<div class="formControls col-xs-8 col-sm-9">
				张三丰
			</div>
		</div>-->
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">转跟进人：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal" id="userList">
				
				 <!-- <div class="radio-box">
					<input type="radio"  name="demo-radio1"/>
					<label for="radio-1">张三峰</label>
				  </div>
				  
				  <div class="radio-box">
					<input type="radio"  name="demo-radio1" value="1" checked>
					<label for="radio-2">张三丰 </label>
				  </div>
				  <div class="radio-box">
					<input type="radio"  name="demo-radio1" />
					<label for="radio-3">李四 </label>
				  </div>
				  <div class="radio-box">
					<input type="radio"  name="demo-radio1" />
					<label for="radio-4">王五 </label>
				  </div>
				  <div class="radio-box">
					<input type="radio" id="radio-1" name="demo-radio1"/>
					<label for="radio-1">张三峰</label>
				  </div>
				  <div class="radio-box">
					<input type="radio" id="radio-2" name="demo-radio1" >
					<label for="radio-2">张三丰 </label>
				  </div>
				  <div class="radio-box">
					<input type="radio" id="radio-3" name="demo-radio1" />
					<label for="radio-3">李四 </label>
				  </div>
				  <div class="radio-box">
					<input type="radio" id="radio-4" name="demo-radio1" />
					<label for="radio-4">王五 </label>
				  </div>-->
  
			</div>
		</div>
		
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button id="infoManageSave" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<!--<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>-->
			</div>
		</div>
	</form>
</div>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js" th:src="@{/lib/jquery/1.9.1/jquery.min.js}"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"  th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" src="h-ui/js/H-ui.min.js"  th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" src="h-ui.admin/js/H-ui.admin.js"  th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">

/*function followSave(){
	alert("刷新父级的时候会自动关闭弹层。")
	window.parent.location.reload();
}*/

$(function(){
	//加载用户信息列表
	//设置选中用户

    $('#infoManageSave').on('click', function() {
        //var body = $('form').serializeObject();
        //var id = body.id;
        //console.log(body);
       var body = {
            "id":$('#id').val(),
            "followUserId":$('input[name="followRadio"]:checked').val()
        };
        /*var body = {
            "id":'1',
            "followUserId":'2'
        };*/
        var data={"head": window.parent.parent.indexParam.getHead(),"data":body};
        console.log(data);
        $.ajax({
            url:window.parent.parent.indexParam.getUrl('changFollow'),
            type:"POST",
            data:JSON.stringify(data),
            contentType:"application/json",  //缺失会出现URL编码，无法转成json对象
            success:function(result){
                console.log(result);
                if(result.head.respStatus=="00"){
                    alert(result.head.respDesc);
                }else{
                    alert(result.head.respDesc);
                }
            }
        });

    });
    initUserList();//初始化数据
});

function initUserList(){
    /*var head = {
        "requestId": "5681864af839cd7a8504b8d8ff0c532e",
        "appKey": "5681864af839cd7a8504b8d8ff0c532e",
        "userId": "1",
        "requestType": "3"
    };*/
    //var body = $('form').serializeObject();
    //var id = body.id;
    //console.log(body);
    var body = {};
    var data={"head": window.parent.parent.indexParam.getHead(),"data":body};
    //var data={"head": head,"data":body};

    $.ajax({
        url:window.parent.parent.indexParam.getUrl('user/getFollowUsers'),
        type:"POST",
        data:JSON.stringify(data),
        contentType:"application/json",  //缺失会出现URL编码，无法转成json对象
        success:function(result){
            console.log(result);
            if(result.head.respStatus=="00"){
                //alert(result.head.respDesc);
                var html ='';
				$(result.data.rows).each(function (i,item) {
				    var checked='';
                    if(item.userId==$('#followUserId').val()){
                        checked='checked';
                    }
                    html +='<div class="radio-box">';
                    html +='    <label ><input type="radio"  name="followRadio" '+checked+' value="'+item.userId+'"/>'+item.userName+'</label>';
                    html +='</div>';
                });
				$('#userList').html(html);
            }else{
                alert(result.head.respDesc);
            }
        }
    });
}
</script>
</body>
</html>